/**
 多态是面向对象三大特性之一
 什么是多态性？
 对象在运行过程中的多种形态。
 
 多态性我们大概可以分为两类:
 (1)方法的重载与重写
 (2)对象的多态性
 
 例如
 // 用父类的引用指向子类对象(用大的类型去接收小的类型,向上转型,自动转换)
 
 结论:
 在编程时针对抽象类型的编写代码，称为面向抽象编程(或面向接口编程)
 父类通常都定义为抽象类,接口
 */

/*
package com.leo.第五章_面向对象下;

public class U5_L10_多态性介绍 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//Animal cat=new Cat();    //类型转换类型 3个 Cat Dog xiaocat
		//Animal dog=new Dog();
		Animal xiaocat=new Xiaocat();
		xizao(xiaocat);
	}
	
	public static void xizao(Animal c) {
		Xiaocat animal=(Xiaocat)c;
		animal.getinfo();
	}
}

abstract class Animal{
	protected String name;
	protected int age;
	protected Animal() {this.name="ss";this.age=22;}
	protected abstract void eat();
	public abstract void getinfo();
	}

class Dog extends Animal{
	protected String name;
	protected int age;
	public Dog() {
		this.name="xiaodog";
		this.age=21;
		System.out.println("调用无参Dog");
	}
	public Dog(String name,int age) {
		this.name=name;
		this.age=age;
		System.out.println("调用2参Dog");
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	protected void eat() {
		System.out.println("eat ball");
	}
	public void getinfo() {
		System.out.println("name: "+this.name+"age "+this.age);
	}
}

class Cat extends Animal{
	protected String name;
	protected int age;
	public Cat() {
		this.name="xiaohongmao";
		this.age=24;
		System.out.println("调用无参cat");
		}
	public Cat(String name,int age) {
		this.name=name;
		this.age=age;
		System.out.println("调用2参cat");
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	protected void eat() {
		System.out.println(this.age+"岁的"+this.name+" eat meat");
	}
	public void song1() {
		System.out.println("cat song1");
	}
	public void getinfo() {
		System.out.println("调用Cat info：name: "+this.name+"age: "+this.age);
	}
}

class Xiaocat extends Cat{
	private String name;
	private int age;
	public Xiaocat() {
		this.name="小小猫";
		this.age=22;
		System.out.println("调用Xiao cat无参");}
	public Xiaocat(String name,int age) {
		this.name=name;
		this.age=age;
		System.out.println("调用Xiao cat 2参");
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public void song2() {
		System.out.println();
	}
	public void getinfo() {
		System.out.println("调用 xiaocatinfo:name: "+this.name+"age "+this.age);
	}
}
*/

